import {
  patientCardTypeBase,
  patientRelationBase,
  genderBase,
  marriageBase,
  subscribeTypeBase,
  orderStatusBase,
} from './constant';
import * as Base from './constant';
/**
 *
 * @param {*} Array [{ code: 10401, label: '身份证' }]
 * @returns {10401:{ code: 10401, label: '身份证' }}
 */

const transObj = (Array) => {
  const obj = {};
  Array.forEach((item) => {
    obj[item.code] = item;
  });
  return obj;
};

export const patientCardTypeBaseObj = () => {
  return transObj(patientCardTypeBase);
};
export const patientRelationBaseObj = () => {
  return transObj(patientRelationBase);
};
export const genderBaseObj = () => {
  return transObj(genderBase);
};
export const marriageBaseObj = () => {
  return transObj(marriageBase);
};
export const subscribeTypeBaseObj = () => {
  return transObj(subscribeTypeBase);
};
export const orderStatusBaseObj = () => {
  return transObj(orderStatusBase);
};
/**
 * 包含所有枚举的对象
 */
const BaseArray = Object.values(Base)
  .flatMap((item) => item)
  .filter((item) => item.code || item.code === 0);
export const BaseObj = () => {
  return transObj(BaseArray);
};
